import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

class ServerThread extends Thread {
	ServerSocket serverSocket;

	public ServerThread(ServerSocket serverSocket) {
		this.serverSocket = serverSocket;
	}

	@Override
	public void run() {
		Socket s;
		try {
			s = serverSocket.accept();
			ServerThread thread = new ServerThread(serverSocket);
			thread.start();
			System.out.println(s.getInetAddress().getHostAddress());
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					s.getInputStream()));
			String line = reader.readLine();
			Thread.sleep(10000);
			System.out.println(line);
			super.run();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}

public class Server {
	public static void main(String[] args) throws IOException,
			InterruptedException {
		ServerSocket socket = new ServerSocket(1234);
		ServerThread thread = new ServerThread(socket);
		thread.start();
	}
}
